package com.lushu.chapitre1.dialogue.nodes
{
	import com.lushu.chapitre1.dialogue.api.INode;

	public class TextNode extends AbstractNode
	{	
		
		private var regExpPattern : RegExp = /\\n/g;
		
		public function TextNode()
		{
			type_ = "text";
		}
		
		public override function toXML(level : int = 0) : String
		{
			var tabIndex : String ="";
			for(var j : int = 0; j < level; j++)
			{
				tabIndex+="\t";
			}
			var nodeXML : String = tabIndex+"<text>"+data_+"</text>";
			return nodeXML;
		}
		
		public function switchToComplexTextNode() : void
		{
			var complexTextNode : ComplexTextNode = new ComplexTextNode();
			var prevParent : INode = this.parent;
			prevParent.replaceChild(this, complexTextNode);
			complexTextNode.addChild(this);
		}
		
		public override function setInformation(value : XML) : void
		{
			data_ = value.toString();
		}

	}
}